﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using WPFExcelReport.Helpers;
using System.Collections.Generic;
namespace WPFExcelReport
{
    public partial class TPART
    {
        public TPART()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VTXTKON();
            this.DataContext = MV;
            InitializeComponent();
        }

        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            base.Window_Loaded(sender, e);
            TP = "90";
        }


        public override void OnEdit()
        {
            DEFTPTEXT();
            base.OnEdit();
        }
        public override void PINDLOAD(string pind)
        {
            TBMain.Clear();
            ReSetTXT();
            if (pind.Length == 0)
                return;
            dwData = TBMain.NewRow();
            dwData["TXTKMANDANT"] = app.Mandant;
            dwData["TXTKPIND"] = pind;
            dwData["TXTKFILLER"] = " AND TXTKFILLER='" + TP + "'";
            SResult = TMV.QTXT05(dwData);
            MergeData(SResult, true, true);
            GetTPTxt();
            DEFTPTEXT();
        }

        public override void OnTA11SChg(string user)
        {
            if (user.Trim().Length == 0)
                return;
            TPSave(TA11DT, user, 1, 2, true);
            base.OnTA11SChg(user);
        }
        public override void OnTA11DTChg(string date)
        {
            if (date.Trim().Length == 0)
                return;
            TPSave(date, TA11S, 1, 2, true);
            base.OnTA11DTChg(date);
        }
        public override void OnTA21SChg(string user)
        {
            if (user.Trim().Length == 0)
                return;
            TPSave(TA21DT, user, 2, 3, true);
            base.OnTA21SChg(user);
        }
        public override void OnTA21DTChg(string date)
        {
            if (date.Trim().Length == 0)
                return;
            TPSave(date, TA21S, 2, 3, true);
            base.OnTA21DTChg(date);
        }
        public override void OnTA31SChg(string user)
        {
            if (user.Trim().Length == 0)
                return;
            TPSave(TA31DT, user, 3, 4, true);
            base.OnTA31SChg(user);
        }
        public override void OnTA31DTChg(string date)
        {
            if (date.Trim().Length == 0)
                return;
            TPSave(date, TA31S, 3, 4, true);
            base.OnTA31DTChg(date);
        }
        public override void OnTA41SChg(string user)
        {
            if (user.Trim().Length == 0)
                return;
            TPSave(TA41DT, user, 4, 5, true);
            base.OnTA41SChg(user);
        }
        public override void OnTA41DTChg(string date)
        {
            if (date.Trim().Length == 0)
                return;
            TPSave(date, TA41S, 4, 5, true);
            base.OnTA41DTChg(date);
        }
        public override void OnTA51SChg(string user)
        {
            TPSave(TA51DT, user, 5, 6, true);
            base.OnTA51SChg(user);
        }
        public override void OnTA51DTChg(string date)
        {
            if (date.Trim().Length == 0)
                return;
            TPSave(date, TA51S, 5, 6, true);
            base.OnTA51DTChg(date);
        }
        public override void OnTA61SChg(string user)
        {
            if (user.Trim().Length == 0)
                return;
            TPSave(TA61DT, user, 6, 7, true);
            base.OnTA61SChg(user);
        }
        public override void OnTA61DTChg(string date)
        {
            if (date.Trim().Length == 0)
                return;
            TPSave(date, TA61S, 6, 7, true);
            base.OnTA61DTChg(date);
        }
        public override void OnTA71SChg(string user)
        {
            if (user.Trim().Length == 0)
                return;
            TPSave(TA71DT, user, 7, 8, true);
            base.OnTA71SChg(user);
        }
        public override void OnTA71DTChg(string date)
        {
            if (date.Trim().Length == 0)
                return;
            TPSave(date, TA71S, 7, 8, true);
            base.OnTA71DTChg(date);
        }
        public override void OnTA81SChg(string user)
        {
            if (user.Trim().Length == 0)
                return;
            TPSave(TA81DT, user, 8, 9, true);
            base.OnTA81SChg(user);
        }
        public override void OnTA81DTChg(string date)
        {
            if (date.Trim().Length == 0)
                return;
            TPSave(date, TA81S, 8, 9, true);
            base.OnTA81DTChg(date);
        }
        public override void OnTA91SChg(string user)
        {
            if (user.Trim().Length == 0)
                return;
            TPSave(TA91DT, user, 9, 10, true);
            base.OnTA91SChg(user);
        }
        public override void OnTA91DTChg(string date)
        {
            if (date.Trim().Length == 0)
                return;
            TPSave(date, TA91S, 9, 10, true);
            base.OnTA91DTChg(date);
        }

        public override void OnSave()
        {
            if (!IsSaved)
                return;
        }


        public override void DEFTPTEXT()
        {
            if (TBMain.Rows.Count > 0)
                return;
            if (IsL1)
            {
                string txt = "";
                txt = "0001- ";//+ MV.date + app.User;
                TMV.InsertLine(txt);
                txt = "0001- ";//+ MV.date + app.User;
                TMV.InsertLine(txt);

                txt = "0002- ";//+ MV.date + app.User;
                TMV.InsertLine(txt);
                txt = "0002- ";//+ MV.date + app.User;
                TMV.InsertLine(txt);

                txt = "0003- ";//+ MV.date + app.User;
                TMV.InsertLine(txt);
                txt = "0003- ";//备注
                TMV.InsertLine(txt);

                txt = "0004-";//+ MV.date + app.User;
                TMV.InsertLine(txt);
                txt = "0004-";//+ MV.date + app.User;
                TMV.InsertLine(txt);

                txt = "0005-";//+ MV.date + app.User;
                TMV.InsertLine(txt);
                txt = "0005- ";//备注
                TMV.InsertLine(txt);

                txt = "0006-";//+ MV.date + app.User;
                TMV.InsertLine(txt);
                txt = "0006- ";//备注

                TMV.InsertLine(txt);

                txt = "0007-";//+ MV.date + app.User;
                TMV.InsertLine(txt);
                txt = "0007- ";//备注 
                TMV.InsertLine(txt);

                txt = "0008- ";//+ MV.date + app.User;
                TMV.InsertLine(txt);
                txt = "0008- ";//备注
                TMV.InsertLine(txt);

                txt = "0009- ";//+ MV.date + app.User;
                TMV.InsertLine(txt);
                txt = "0009- ";//备注
                TMV.InsertLine(txt);
                TMV.POSTCHG();
            }
            GetTPTxt();
        }
    }
}
